<template>
  <div v-if="show" class="character-modal-overlay" @click="emit('close')">
    <div class="character-modal-container" @click.stop>
      <div class="character-modal-card" :class="{ 'show': show }">
        
        <div class="modal-content" v-if="character">
          <!-- 关闭按钮 -->
          <button class="close-button" @click="emit('close')">
            <el-icon><Close /></el-icon>
          </button>

          <!-- 背景装饰 -->
          <div class="hero-background">
            <div class="gradient-orb orb-1"></div>
            <div class="gradient-orb orb-2"></div>
            <div class="gradient-orb orb-3"></div>
            <div class="floating-particles">
              <div class="particle" v-for="i in 12" :key="i" :style="getParticleStyle(i)"></div>
            </div>
          </div>
          
          <!-- 角色主要信息卡片 -->
          <div class="character-hero-card">
            <div class="character-avatar-section">
              <div class="avatar-container">
                <div class="avatar-ring" :style="{ background: characterGradient }"></div>
                <div class="avatar-main" :style="{ background: characterGradient }">
                  <img 
                    v-if="characterAvatarUrl" 
                    :src="characterAvatarUrl" 
                    :alt="character?.name" 
                    class="character-avatar-image"
                    @error="handleImageError"
                  />
                  <div v-else class="character-emoji">{{ characterEmoji }}</div>
                </div>
                <div class="avatar-glow" :style="{ boxShadow: `0 0 40px ${characterGradient.includes('linear') ? '#667eea' : characterGradient}40` }"></div>
              </div>
              
              <div class="character-basic-info">
                <h1 class="character-name">{{ character.name }}</h1>
                <div class="character-role-badge" :style="{ background: characterGradient }">
                  {{ characterRole }}
                </div>
                <div class="character-source-tag">
                  <el-icon><Reading /></el-icon>
                  {{ $t('novel.fromNovel', { title: novelTitle }) }}
                </div>
              </div>
            </div>
          </div>

          <!-- 角色详细信息网格 -->
          <div class="character-details-grid">
            
            <!-- 角色描述卡片 -->
            <div class="detail-card description-card">
              <div class="card-header">
                <div class="card-icon">📝</div>
                <h3>{{ $t('novel.characterIntro') }}</h3>
              </div>
              <div class="card-content">
                <p>{{ character.description || $t('novel.mysteriousCharacter') }}</p>
              </div>
            </div>

            <!-- 性格特点卡片 -->
            <div class="detail-card tags-card" v-if="character.tags && character.tags.length > 0">
              <div class="card-header">
                <div class="card-icon">🏷️</div>
                <h3>{{ $t('novel.personalityTraits') }}</h3>
              </div>
              <div class="card-content">
                <div class="tags-grid">
                  <span v-for="tag in character.tags" :key="tag" class="character-tag">
                    {{ tag }}
                  </span>
                </div>
              </div>
            </div>

            <!-- 背景故事卡片 -->
            <div class="detail-card background-card" v-if="newCharacter && newCharacter.background">
              <div class="card-header">
                <div class="card-icon">📚</div>
                <h3>{{ $t('novel.backgroundStory') }}</h3>
              </div>
              <div class="card-content">
                <p>{{ newCharacter.background }}</p>
              </div>
            </div>

            <!-- 性格特征卡片 -->
            <div class="detail-card personality-card" v-if="newCharacter && newCharacter.personality">
              <div class="card-header">
                <div class="card-icon">🎭</div>
                <h3>{{ $t('novel.personality') }}</h3>
              </div>
              <div class="card-content">
                <p>{{ newCharacter.personality }}</p>
              </div>
            </div>

            <!-- 角色能力卡片 -->
            <div class="detail-card abilities-card" v-if="newCharacter && newCharacter.abilities && Object.keys(newCharacter.abilities).length">
              <div class="card-header">
                <div class="card-icon">⚡</div>
                <h3>{{ $t('novel.abilities') }}</h3>
              </div>
              <div class="card-content">
                <div class="abilities-grid">
                  <div v-for="(value, key) in newCharacter.abilities" :key="key" class="ability-item">
                    <div class="ability-header">
                      <span class="ability-name">{{ typeof value === 'string' ? value : key }}</span>
                      <span class="ability-level" v-if="typeof key === 'string' && !isNaN(Number(key))">
                        <div class="level-stars">
                          <el-icon v-for="i in 5" :key="i" :class="{ 'filled': i <= (Number(key) + 1) }"><Star /></el-icon>
                        </div>
                      </span>
                      <span class="ability-level" v-else-if="typeof value === 'number'">
                        <div class="level-stars">
                          <el-icon v-for="i in 5" :key="i" :class="{ 'filled': i <= (value + 1) }"><Star /></el-icon>
                        </div>
                      </span>
                    </div>
                    <div class="ability-description" v-if="typeof value === 'string' && typeof key !== 'string' || (typeof key === 'string' && isNaN(Number(key)))">{{ value }}</div>
                    <div class="ability-progress" v-if="typeof key === 'string' && !isNaN(Number(key))">
                      <div class="progress-bar" :style="{ width: `${((Number(key) + 1) / 5) * 100}%` }"></div>
                    </div>
                    <div class="ability-progress" v-else-if="typeof value === 'number'">
                      <div class="progress-bar" :style="{ width: `${((value + 1) / 5) * 100}%` }"></div>
                    </div>
                  </div>
                </div>
              </div>
            </div>

            <!-- 人物关系卡片 -->
            <div class="detail-card relationships-card" v-if="newCharacter && newCharacter.relationships && Object.keys(newCharacter.relationships).length">
              <div class="card-header">
                <div class="card-icon">👥</div>
                <h3>{{ $t('novel.relationships') }}</h3>
              </div>
              <div class="card-content">
                <div class="relationships-grid">
                  <div v-for="(relation, person) in newCharacter.relationships" :key="person" class="relationship-item">
                    <div class="relationship-avatar">
                      <div class="relation-icon">👤</div>
                    </div>
                    <div class="relationship-info">
                      <div class="person-name">{{ person }}</div>
                      <div class="relation-description">{{ relation }}</div>
                    </div>
                  </div>
                </div>
              </div>
            </div>

          </div>

          <!-- 操作按钮区域 -->
          <div class="modal-actions">
            <el-button size="large" @click="emit('close')" class="cancel-btn">
              <el-icon><Back /></el-icon>
              {{ $t('novel.backToSelection') }}
            </el-button>
            <el-button type="primary" size="large" @click="emit('startChat')" class="start-chat-btn">
              <el-icon><ChatLineRound /></el-icon>
              {{ $t('novel.startChat') }}
              <div class="btn-sparkle">✨</div>
            </el-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { Back, ChatLineRound, Close, Reading, Star } from '@element-plus/icons-vue'
import type { Character, LegacyCharacter } from '../../types/novel'

interface Props {
  show: boolean
  character: Character | LegacyCharacter | null
  novelTitle?: string
}

const props = defineProps<Props>()

const emit = defineEmits<{
  close: []
  startChat: []
}>()

const { t } = useI18n()

// 计算属性用于兼容新旧数据结构
const characterGradient = computed(() => {
  if (!props.character) return 'linear-gradient(135deg, #667eea, #764ba2)'
  
  // 如果是旧格式的角色数据
  if ('color' in props.character) {
    return (props.character as LegacyCharacter).color
  }
  
  // 新格式默认渐变
  return 'linear-gradient(135deg, #667eea, #764ba2)'
})

const characterEmoji = computed(() => {
  if (!props.character) return '👤'
  
  // 如果是旧格式的角色数据
  if ('emoji' in props.character) {
    return (props.character as LegacyCharacter).emoji
  }
  
  // 新格式默认头像或从avatar_image获取
  return '👤'
})

const characterAvatarUrl = computed(() => {
  if (!props.character) return null
  
  // 如果是新格式的角色数据并且有头像图片
  if ('avatar_image' in props.character && props.character.avatar_image) {
    return props.character.avatar_image
  }
  
  return null
})

const handleImageError = () => {
  console.warn('角色头像加载失败:', props.character?.name)
}

const characterRole = computed(() => {
  if (!props.character) return ''
  
  if ('role' in props.character) {
    return (props.character as LegacyCharacter).role
  }
  
  const roleTypeKey = props.character.role_type
  if (roleTypeKey && ['protagonist', 'supporting', 'antagonist', 'minor'].includes(roleTypeKey)) {
    return t(`novel.roleTypes.${roleTypeKey}`)
  }
  return t('novel.roleTypes.minor')
})

const novelTitle = computed(() => {
  if (props.novelTitle) return props.novelTitle
  
  if (!props.character) return ''
  
  // 如果是旧格式的角色数据
  if ('novel' in props.character) {
    return (props.character as LegacyCharacter).novel
  }
  
  return t('common.unknown')
})

// 判断是否为新格式角色数据
const isNewCharacter = computed(() => {
  if (!props.character) return false
  return 'role_type' in props.character
})

// 获取新格式角色数据
const newCharacter = computed(() => {
  if (!isNewCharacter.value) return null
  return props.character as Character
})

// 生成粒子样式
const getParticleStyle = (index: number) => {
  const angle = (index * 30) % 360
  const delay = index * 0.2
  const size = 3 + (index % 3)
  
  return {
    '--angle': `${angle}deg`,
    '--delay': `${delay}s`,
    '--size': `${size}px`,
    animationDelay: `${delay}s`
  }
}
</script>

<script lang="ts">
export default {
  name: 'CharacterModal'
}
</script>

<style scoped>
/* 现代化角色名片样式 */
.character-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { 
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to { 
    opacity: 1;
    backdrop-filter: blur(12px);
  }
}

.character-modal-container {
  width: 95%;
  max-width: 800px;
  max-height: 95vh;
  overflow-y: auto;
  perspective: 1200px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.character-modal-container::-webkit-scrollbar {
  display: none;
}

.character-modal-card {
  background: linear-gradient(145deg, #ffffff, #f8fafc);
  border-radius: 32px;
  box-shadow: 
    0 32px 120px rgba(0, 0, 0, 0.25),
    0 16px 60px rgba(102, 126, 234, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transform: scale(0.8) translateY(40px);
  opacity: 0;
  transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.character-modal-card.show {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.modal-content {
  padding: 0;
  position: relative;
  z-index: 3;
}

/* 关闭按钮 */
.close-button {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  color: #6b7280;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.close-button:hover {
  background: rgba(255, 255, 255, 1);
  color: #374151;
  transform: scale(1.1);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

/* 背景装饰元素 */
.hero-background {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 320px;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
  border-radius: 32px 32px 0 0;
}

.gradient-orb {
  position: absolute;
  border-radius: 50%;
  opacity: 0.6;
  filter: blur(40px);
  animation: orbFloat 8s ease-in-out infinite;
}

.orb-1 {
  width: 200px;
  height: 200px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  top: -50px;
  left: -50px;
  animation-delay: 0s;
}

.orb-2 {
  width: 150px;
  height: 150px;
  background: linear-gradient(135deg, #f093fb, #f5576c);
  top: 50px;
  right: -30px;
  animation-delay: 2s;
}

.orb-3 {
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, #4facfe, #00f2fe);
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  animation-delay: 4s;
}

@keyframes orbFloat {
  0%, 100% { 
    transform: translateY(0px) scale(1);
    opacity: 0.6;
  }
  50% { 
    transform: translateY(-20px) scale(1.1);
    opacity: 0.8;
  }
}

.floating-particles {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.particle {
  position: absolute;
  width: var(--size);
  height: var(--size);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, transparent 70%);
  border-radius: 50%;
  animation: particleFloat 6s linear infinite;
  top: 50%;
  left: 50%;
}

@keyframes particleFloat {
  0% {
    transform: translate(-50%, -50%) rotate(var(--angle)) translateX(0px) rotate(calc(-1 * var(--angle)));
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) rotate(var(--angle)) translateX(200px) rotate(calc(-1 * var(--angle)));
    opacity: 0;
  }
}

/* 角色主要信息卡片 */
.character-hero-card {
  position: relative;
  z-index: 2;
  padding: 40px 40px 20px;
}

.character-avatar-section {
  display: flex;
  align-items: center;
  gap: 32px;
  margin-bottom: 20px;
}

.avatar-container {
  position: relative;
  flex-shrink: 0;
}

.avatar-ring {
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  border-radius: 50%;
  opacity: 0.3;
  animation: ringPulse 3s ease-in-out infinite;
}

@keyframes ringPulse {
  0%, 100% { 
    transform: scale(1);
    opacity: 0.3;
  }
  50% { 
    transform: scale(1.05);
    opacity: 0.6;
  }
}

.avatar-main {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 3;
  border: 4px solid rgba(255, 255, 255, 0.9);
  box-shadow: 
    0 16px 48px rgba(0, 0, 0, 0.2),
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.4s ease;
}

.avatar-main:hover {
  transform: scale(1.05);
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
}

.character-emoji {
  font-size: 64px;
  animation: emojiFloat 4s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.character-avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  animation: emojiFloat 4s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

@keyframes emojiFloat {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(2deg); }
}

.avatar-glow {
  position: absolute;
  top: -20px;
  left: -20px;
  right: -20px;
  bottom: -20px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  animation: glowPulse 4s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { 
    transform: scale(0.8);
    opacity: 0.5;
  }
  50% { 
    transform: scale(1.1);
    opacity: 0.8;
  }
}

.character-basic-info {
  flex: 1;
  min-width: 0;
}

.character-name {
  font-size: 42px;
  font-weight: 900;
  background: linear-gradient(135deg, #1f2937, #374151);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0 0 16px 0;
  line-height: 1.1;
  letter-spacing: -1px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.character-role-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 20px;
  border-radius: 20px;
  color: white;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  animation: badgeShimmer 3s ease-in-out infinite;
}

@keyframes badgeShimmer {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.character-source-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid rgba(102, 126, 234, 0.2);
  border-radius: 24px;
  color: #4b5563;
  font-size: 16px;
  font-weight: 600;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.character-source-tag:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(102, 126, 234, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* 详细信息网格 */
.character-details-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  padding: 0 40px 40px;
}

.detail-card {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 24px;
  padding: 0;
  overflow: hidden;
  transition: all 0.4s ease;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.detail-card:hover {
  transform: translateY(-4px);
  box-shadow: 
    0 16px 48px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  border-color: rgba(102, 126, 234, 0.3);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 28px 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(248, 250, 252, 0.9));
  border-bottom: 1px solid rgba(229, 231, 235, 0.5);
}

.card-icon {
  font-size: 24px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 16px;
  color: white;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

.card-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
}

.card-content {
  padding: 24px 28px;
}

.card-content p {
  color: #4b5563;
  line-height: 1.7;
  font-size: 16px;
  margin: 0;
}

/* 标签网格 */
.tags-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.character-tag {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 12px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 
    0 4px 16px rgba(102, 126, 234, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.character-tag::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.character-tag:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 8px 24px rgba(102, 126, 234, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.character-tag:hover::before {
  left: 100%;
}

/* 能力展示 */
.abilities-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.ability-item {
  background: linear-gradient(135deg, rgba(248, 250, 252, 0.8), rgba(255, 255, 255, 0.8));
  border: 1px solid rgba(229, 231, 235, 0.5);
  border-radius: 16px;
  padding: 20px;
  transition: all 0.3s ease;
}

.ability-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border-color: rgba(102, 126, 234, 0.3);
}

.ability-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.ability-name {
  font-size: 16px;
  font-weight: 700;
  color: #374151;
}

.ability-level {
  display: flex;
  align-items: center;
}

.level-stars {
  display: flex;
  gap: 2px;
}

.level-stars .el-icon {
  font-size: 16px;
  color: #d1d5db;
  transition: all 0.2s ease;
}

.level-stars .el-icon.filled {
  color: #fbbf24;
  animation: starGlow 1s ease-in-out infinite alternate;
}

@keyframes starGlow {
  0% { transform: scale(1); }
  100% { transform: scale(1.1); }
}

.ability-description {
  color: #6b7280;
  font-size: 14px;
  line-height: 1.5;
  margin-top: 8px;
}

.ability-progress {
  height: 8px;
  background: rgba(229, 231, 235, 0.5);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 12px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2, #f093fb);
  border-radius: 4px;
  transition: width 1s ease;
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: progressShine 2s ease-in-out infinite;
}

@keyframes progressShine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* 关系展示 */
.relationships-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.relationship-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: linear-gradient(135deg, rgba(248, 250, 252, 0.8), rgba(255, 255, 255, 0.8));
  border: 1px solid rgba(229, 231, 235, 0.5);
  border-radius: 16px;
  transition: all 0.3s ease;
}

.relationship-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border-color: rgba(102, 126, 234, 0.3);
}

.relationship-avatar {
  flex-shrink: 0;
}

.relation-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
  border-radius: 50%;
  font-size: 24px;
  color: #6b7280;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.relationship-info {
  flex: 1;
  min-width: 0;
}

.person-name {
  font-size: 16px;
  font-weight: 700;
  color: #374151;
  margin-bottom: 4px;
}

.relation-description {
  color: #6b7280;
  font-size: 14px;
  line-height: 1.5;
}





/* 操作按钮 */
.modal-actions {
  display: flex;
  gap: 16px;
  padding: 32px 40px;
  background: linear-gradient(135deg, rgba(248, 250, 252, 0.8), rgba(255, 255, 255, 0.8));
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(229, 231, 235, 0.5);
}

.cancel-btn {
  flex: 1;
  height: 56px;
  border-radius: 28px;
  font-weight: 600;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid rgba(209, 213, 219, 0.5);
  color: #6b7280;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(10px);
}

.cancel-btn:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(156, 163, 175, 0.8);
  color: #374151;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.start-chat-btn {
  flex: 2;
  height: 56px;
  border-radius: 28px;
  font-weight: 700;
  font-size: 16px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  color: white;
  box-shadow: 
    0 8px 32px rgba(102, 126, 234, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.start-chat-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.start-chat-btn:hover {
  transform: translateY(-3px);
  box-shadow: 
    0 12px 40px rgba(102, 126, 234, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.start-chat-btn:hover::before {
  left: 100%;
}

.btn-sparkle {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 16px;
  animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% { 
    transform: scale(1) rotate(0deg);
    opacity: 0.8;
  }
  50% { 
    transform: scale(1.2) rotate(180deg);
    opacity: 1;
  }
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .character-details-grid {
    padding: 0 32px 32px;
  }
  
  .character-hero-card {
    padding: 32px 32px 16px;
  }
  
  .modal-actions {
    padding: 24px 32px;
  }
}

@media (max-width: 768px) {
  .character-modal-container {
    width: 95%;
    max-width: none;
    margin: 20px;
  }
  
  .character-modal-card {
    border-radius: 24px;
  }
  
  .hero-background {
    height: 240px;
    border-radius: 24px 24px 0 0;
  }
  
  .character-hero-card {
    padding: 24px 24px 16px;
  }
  
  .character-avatar-section {
    flex-direction: column;
    text-align: center;
    gap: 20px;
  }
  
  .avatar-main {
    width: 100px;
    height: 100px;
  }
  
  .character-emoji {
    font-size: 48px;
  }
  
  .character-name {
    font-size: 32px;
  }
  
  .character-details-grid {
    padding: 0 24px 24px;
    gap: 20px;
  }
  
  .card-header {
    padding: 20px 24px 12px;
  }
  
  .card-content {
    padding: 20px 24px;
  }
  
  .modal-actions {
    flex-direction: column;
    padding: 24px;
    gap: 12px;
  }
  
  .cancel-btn,
  .start-chat-btn {
    flex: none;
    height: 52px;
  }
  
  .close-button {
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .character-modal-container {
    width: 100%;
    height: 100vh;
    max-height: none;
    margin: 0;
  }
  
  .character-modal-card {
    border-radius: 0;
    height: 100vh;
  }
  
  .hero-background {
    border-radius: 0;
  }
  
  .character-hero-card {
    padding: 20px 20px 12px;
  }
  
  .character-details-grid {
    padding: 0 20px 20px;
  }
  
  .card-header {
    padding: 16px 20px 10px;
  }
  
  .card-content {
    padding: 16px 20px;
  }
  
  .modal-actions {
    padding: 20px;
  }
}
</style> 